home *** CD-ROM | disk | FTP | other *** search
- OPT OSVERSION=37
-
- MODULE 'asl', 'libraries/asl', 'tools/EasyGUI_lite', 'tools/file',
- 'tools/thx-play', 'utility/tagitem'
-
- DEF mod=NIL,len,stopped=FALSE,song=0
-
- PROC main() HANDLE
- easyguiA('PlayTHX',
- [ROWS,
- [EQCOLS,
- [SBUTTON,{psub}, '|<', 0,0],
- [SBUTTON,{rew}, '<<', 0,0],
- [SBUTTON,{play}, 'Play', 0,0],
- [SBUTTON,{ffwd}, '>>', 0,0],
- [SBUTTON,{nsub}, '>|', 0,0]
- ],
- [EQCOLS,
- [SBUTTON,{stop}, 'Stop', 0,0],
- [SBUTTON,{eject},'Eject', 0,0],
- [SBUTTON,{open}, 'Open...', 0,0]
- ]
- ],0
- )
- Raise()
- EXCEPT
- eject() -> free module (if loaded)
- thxFree() -> free player
- ENDPROC
-
- PROC rew() IS IF mod THEN thxWind(-1) ELSE 0
- PROC ffwd() IS IF mod THEN thxWind(1) ELSE 0
-
- PROC psub()
- stop()
- IF song>0 THEN thxSetSong(song:=song-1)
- play()
- ENDPROC
-
- PROC nsub()
- stop()
- IF song<thxGetNumSongs() THEN thxSetSong(song:=song+1)
- play()
- ENDPROC
-
-
- PROC stop()
- IF mod=NIL THEN RETURN
- thxStop()
- stopped:=TRUE -> mark as stopped
- ENDPROC
-
- PROC eject()
- IF mod=NIL THEN RETURN
- stop()
- freefile(mod) -> free module
- mod:=NIL -> mark as freed
- ENDPROC
-
- PROC play()
- IF mod=NIL THEN RETURN
-
- IF stopped
- thxSetVolume(64)
- thxPlay() -> start playing
- stopped:=FALSE -> no longer stopped
- ELSE
- -> if playing (not stopped)
- thxSetVolume(0)
- Delay(2) -> dirty kludge (setvolume needs 'a while' to happen)
- thxPause() -> pause
- stopped:=TRUE -> paused is ~same as stopped :)
- ENDIF
- ENDPROC
-
- PROC open() HANDLE
- DEF file
- IF (file:=asl_req())=0 THEN RETURN -> return if no file selected
-
- eject() -> eject current module
-
- mod,len:=readfile(file) -> read new module
- DisposeLink(file) -> free memory of 'file' string (pedantic)
-
- IF mod=NIL THEN Raise(1) -> no mod loaded? give up
- IF thxInit(mod)<>0 THEN Raise(1) -> thxInit() failed? give up
-
- song:=0
- stopped:=TRUE
- play()
-
- EXCEPT
- IF exception THEN eject()
- ENDPROC
-
-
- ->----- an asl requester
-
- PROC asl_req(title=NIL,dir=NIL,save=FALSE)
- DEF req:PTR TO filerequester, file=NIL, tail=0
- IF aslbase=NIL THEN aslbase:=OpenLibrary('asl.library',37)
- IF aslbase=NIL THEN RETURN NIL
-
- IF req:=AllocAslRequest(ASL_FILEREQUEST,0)
- IF AslRequest(req,[ASLFR_INITIALDRAWER,dir,
- ASLFR_TITLETEXT,IF title THEN title ELSE 'Select file...',
- ASLFR_FLAGS1,IF save THEN FRF_DOSAVEMODE ELSE 0,
- TAG_DONE
- ])
- IF file:=String(StrLen(req.drawer)+StrLen(req.file)+1)
- StrCopy(file,req.drawer)
- IF StrLen(req.drawer) THEN tail:=Char(req.drawer+StrLen(req.drawer)-1)
- IF (tail<>":") AND (tail<>"/") AND (tail<>0) THEN StrAdd(file,'/')
- StrAdd(file,req.file)
- ENDIF
- ENDIF
- FreeAslRequest(req)
- ENDIF
- ENDPROC file
-